<?php

class Quiz_Model extends CI_Model {

    public function __construct() {
        parent::__construct();
    }

    private $tabel = 'braintest';

    public function tambahQuiz($nama, $deskripsi, $waktuMulai, $waktuSelesai) {
        $data = array(
            'nama_braintest' => $nama,
            'deskripsi' => $deskripsi,
            'waktu_mulai' => "STR_TO_DATE('$waktuMulai', '%d-%m-%Y')",
            'waktu_selesai' => "STR_TO_DATE('$waktuSelesai', '%d-%m-%Y')"
        );
        //return $this->db->insert($this->tabel,$data);
        $sql = "insert into $this->tabel (nama_braintest,deskripsi,waktu_mulai,waktu_selesai) values("
                . "'$nama','$deskripsi',STR_TO_DATE('$waktuMulai', '%d-%m-%Y'),STR_TO_DATE('$waktuSelesai', '%d-%m-%Y'))";
        //echo $sql;
        $this->db->query($sql);
        return  mysql_insert_id();
        
    }
    
    public function getListQuiz() {
        $query = "select * from braintest order by waktu_mulai";
        $query = $this->db->query($query);
        return $query->result();
        
    }

}
